function states_ = gXrandom_statelist(varargin)

% stimulus viewing time
show = 3e4;

% confirm-or-modify-response time
hang = 200;

noTouch = { ...
    'dXkbHID',  {'any', 'error'}; ...
    'dXlpHID',  {'any', 'error'}};

respond = { ...
    'dXkbHID',  {'j', 'right', 'f', 'left'}; ...
    'dXlpHID',  {'r2on', 'right', 'l2on', 'left'}};

left = { ...
    'dXkbHID',  {'j', 'both'}; ...
    'dXlpHID',  {'r2on', 'both'}};
right = { ...
    'dXkbHID',  {'f', 'both'}; ...
    'dXlpHID',  {'l2on', 'both'}};

lcon = {'jump', {'dXfunctionCaller', 1, 'ans'}, [0 1], {'correct'; 'incorrect'}};
rcon = {'jump', {'dXfunctionCaller', 1, 'ans'}, [0 1], {'incorrect'; 'correct'}};

rP = @rPlay;
rH = @rGraphicsShow;
rU = @rVarUpdate;
rC = @rCallFunction;
nxt = 'next';
err = 'error';
tx = 'dXtext';
dr = 'dXdistr';
bp = 'dXbeep';

% THE STATE DINNER. Careful -- this MUST be a double cellery.
%
%   You know those guitars that are like *double* guitars?
%
%   name        fun args        jump    wait    repsDrawQuery   cond
arg_dXstate = {{ ...
    'clear',	{}, {}          nxt,    0,      0,  5,  noTouch,{}; ...
    'compare',  rC, {1},        nxt,    0,      0,  0,  1,      {}; ...
    'sendNum',  rU, {dr},       nxt,    0,      0,  0,  1,      {}; ...
    'showNum',  rH, {tx,1},     err,    show,	0,  3,  respond,{}; ...
    'left',     {}, {},         err,    hang,	0,  0,  left,   lcon; ...
    'right',    {}, {},         err,    hang,	0,  0,  right,  rcon; ...
    'both',     {}, {},         err,    0,      0,  0,  0,      {}; ...
    ...
    'correct',  rP, {bp, 2},	'end',  500,    0,  0,  0,      {}; ...
    'incorrect',rP, {bp, 3},    'end',  250,    1,  0,  0,      {}; ...
    'error',    {}, {},         nxt,    0,      0,  5,  0,      {}; ...
    'errBeep',	rP, {bp, 1},    'end',	100,    4,  0,  0,      {}; ...
    'end',      {}, {},         'x',    0,      0,  5,  0,      {}; ...
    }};
sz = size(arg_dXstate{1}, 1);

tony = {'current', true, true, false};
states_ = {'dXstate', sz, tony, arg_dXstate};